package com.xiangxiangjd.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.xiangxiangjd.bean.result.ResultPage;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ResponseBody;
import com.xiangxiangjd.service.ManagementGoodsService;
import com.xiangxiangjd.bean.ManagementGoods;
import com.xiangxiangjd.controller.model.ApiResultModel;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.ArrayList;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 处置的物品 前端控制器
 * </p>
 *
 * @author 肖守凯
 * @since 2021-11-23
 */
@Controller
@RequestMapping("/api/managementGoods")
public class ManagementGoodsController extends BaseController{
    @Autowired
    ManagementGoodsService managementGoodsService;



     /** 主页面 */
    @GetMapping("admin/main.html")
    public String main(){
       return  "ManagementGoods/ManagementGoodsMain";
    }
    /** 添加页面跳转
     * @return 返回页面
     */
    @GetMapping(value = "admin/addManagementGoodsHtml")
    public String addManagementGoodsHtml( ){
             return "ManagementGoods/ManagementGoodsAdd";
    }
    /** 编辑页面跳转
     * @param  id  前端传进的参数
     * @return 返回页面
     */
    @GetMapping(value = "admin/editManagementGoodsHtml")
    public String editManagementGoodsHtml(String id ,Model model ){
           model.addAttribute("managementGoods",managementGoodsService.selectManagementGoodsByIdManagementGoods(id));
             return "ManagementGoods/ManagementGoodsEdit";
    }

    /** 查看页面跳转
     * @param  id  前端传进的参数
     * @return 返回页面
     */
    @PostMapping(value = "admin/showManagementGoodsHtml")
    public String showManagementGoodsHtml(String id ,Model model ){
           model.addAttribute("managementGoods",managementGoodsService.selectManagementGoodsByIdManagementGoods(id));
             return "ManagementGoods/ManagementGoodsShow";
    }


    /** 分页查询ManagementGoods
     * @param page  页码
     * @param limit  查几条
     * @param managementGoods  前端传进的参数
     * @return 返回统一分页信息
     */
    @PostMapping(value = "admin/findManagementGoodsByPage")
    @ResponseBody
    public ResultPage findManagementGoodsByPage(Integer page, Integer limit,ManagementGoods managementGoods){
             return managementGoodsService.findManagementGoodsByPage(page,limit,managementGoods);
    }

    /** 添加ManagementGoods
     * @param managementGoods  前端传进的参数
     * @return 返回统一信息
     */
    @PostMapping(value = "admin/addManagementGoods")
    @ResponseBody
    public ApiResultModel saveManagementGoods(ManagementGoods managementGoods  ){
             return managementGoodsService.addManagementGoods(managementGoods);
    }

    /** 编辑ManagementGoods
     * @param managementGoods  前端传进的参数
     * @return 返回统一信息
     */
    @PostMapping(value = "admin/editManagementGoods")
    @ResponseBody
    public ApiResultModel editManagementGoods(ManagementGoods managementGoods  ){
             return managementGoodsService.editManagementGoods(managementGoods);
    }

    /** 删除ManagementGoods
     * @param ids  前端传进的ID
     * @return 返回统一信息
     */
    @PostMapping(value = "admin/delManagementGoods")
    @ResponseBody
    public ApiResultModel delManagementGoods(@RequestParam("datas") ArrayList ids){


             return managementGoodsService.delManagementGoodss(ids);
    }


}
